feat(store): add Upsert() to BuiltinToolStore for additive tool seeding#554
Open
duhd-vnpay wants to merge 1 commit intonextlevelbuilder:mainfrom
Open
feat(store): add Upsert() to BuiltinToolStore for additive tool seeding#554duhd-vnpay wants to merge 1 commit intonextlevelbuilder:mainfrom
duhd-vnpay wants to merge 1 commit intonextlevelbuilder:mainfrom
Conversation
Seed() performs a reconcile DELETE that removes all tools not in the provided list. This breaks fork workflows where Seed() is called twice: once for upstream tools, once for fork-local additions — the second call wipes all upstream tools. Add Upsert() that performs the same INSERT ON CONFLICT DO UPDATE but skips the reconcile DELETE. Fork-specific seed functions can use Upsert() to additively register tools without affecting the upstream set. Implemented for both PostgreSQL and SQLite backends. Fixes nextlevelbuilder#336 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #336
Problem
BuiltinToolStore.Seed()performs a reconcile DELETE that removes all rows not in the provided list:When a fork calls
Seed()twice — once for 28 upstream tools, then again for 2 fork-local tools — the second call's DELETE wipes all 28 upstream tools. Only the 2 fork tools remain visible.Fix
Add
Upsert()method that performs the sameINSERT ON CONFLICT DO UPDATEasSeed()but skips the reconcile DELETE. Fork-specific seed functions useUpsert()to additively register tools.Behavior comparison
enabled/settingsSeed()Upsert()Both methods preserve user-customized
enabledandsettingsvalues — theON CONFLICTclause only overwritessettingswhen the existing value is{}ornull.Changes
internal/store/builtin_tool_store.goUpsert()to interfaceinternal/store/pg/builtin_tools.gointernal/store/sqlitestore/builtin-tools.goVerification
🤖 Generated with Claude Code